home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DRIVES.SWG / 0002_CHANGDRV.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  4KB  |  83 lines

  1. { Author: Greg Estabrooks }
  2. Program DriveInf;
  3. Uses
  4.   Crt,                        (* ClrScr routine                   *)
  5.   Dos;                        (* Register Type, Intr() Routine    *)
  6. Var
  7.   Regs :Registers;            (* To hold register info For Intr() *)
  8.   CH   :Char;                 (* To hold Drive to change to       *)
  9.  
  10.  
  11. Function GetDrive :Byte;
  12.                 (* Routine to Determine the default drive             *)
  13. begin
  14.   Regs.AX := $1900;                (* Function to determine drive     *)
  15.   Intr($21,Regs);                  (* Call Dos int 21h                *)
  16.   GetDrive := Regs.AL;             (* Return Proper result            *)
  17.         (* Returns  0 = A, 1 = B, 2 = C, ETC                          *)
  18. end;
  19.  
  20. Procedure ChangeDrive( Drive :Byte );
  21.                 (* Routine to change default drive                    *)
  22. begin
  23.   Regs.AH := $0E;                (* Function to change Drives         *)
  24.   Regs.DL := Drive;              (* Drive to change to                *)
  25.   Intr($21,Regs);                (* Call Dos Int 21h                  *)
  26. end;
  27.  
  28. Function NumDrives :Byte;
  29.                 (* Routine to determine number of valid drives        *)
  30. Var
  31.   CurDrive :Byte;             (* Temporary storage For current drive*)
  32. begin
  33.   CurDrive := GetDrive;         (* Find out the current drive         *)
  34.   Regs.AH := $0E;               (* Function to change drives          *)
  35.   Regs.DL := CurDrive;          (* Change to current drive            *)
  36.   Intr($21, Regs);              (* Call Dos                           *)
  37.   NumDrives := Regs.AL;         (* Return proper info to user         *)
  38. end;
  39.  
  40. begin
  41.   ClrScr;                        (* Clear the screen                  *)
  42.                                  (* Write Current Drive to  Screen    *)
  43.   Writeln('Current Drive Is : ',CHR(GetDrive+65 ),':\');
  44.   Write('What Drive do you wish to change to ?[A..');
  45.   WriteLn(CHR(NumDrives + 64 ),']');
  46.   CH := ReadKey;                 (* Get Choice                        *)
  47.   CH := UpCase( CH );            (* Convert to uppercase              *)
  48.   ChangeDrive( Ord( CH )-65 );   (* Change to chosen drive            *)
  49. end.
  50. (**********************************************************************)
  51.  
  52.  
  53. {        And here are the above in Inline Asm. I hope these help. }
  54.  
  55. Function GetDrive :Byte; Assembler;
  56.                     {  Routine to Determine the default drive           }
  57. Asm
  58.   Mov AX,$1900                  {  Function to determine drive          }
  59.   Int $21                       {  Call Dos int 21h                     }
  60.                     { Returns  0 = A, 1 = B, 2 = C, ETC                 }
  61. end;{GetDrive}
  62.  
  63. Procedure ChangeDrive( Drive :Byte ); Assembler;
  64.                     {  Routine to change default drive                  }
  65.                     {  0 = A, 1 = B, 2 = C, ETC                         }
  66. Asm
  67.   Mov AH,$0E                     {  Function to change Drives           }
  68.   Mov DL,Drive                   {  Drive to change to                  }
  69.   Int $21                        {  Call Dos Int 21h                    }
  70. end;{ChangeDrive}
  71.  
  72. Function NumDrives :Byte; Assembler;
  73.                      {  Routine to determine number of valid drives   }
  74. Asm
  75.   Call GetDrive                {  Find out the current drive, Returns }
  76.                                {  Drive in AL                         }
  77.   Mov AH,$0E                   {  Function to change drives           }
  78.   Mov DL,AL                    {  Change to current drive             }
  79.   Int $21                      {  Call Dos                            }
  80.                                {  Number of drives is returns in AL   }
  81. end;{NumDrives}
  82.  
  83.